<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <!-- 避免IE使用兼容模式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <!--<link rel="stylesheet" type="text/css" href="/easyui/themes/metro/easyui.css"/>-->
    <!-- TopJUI框架样式 -->
    <link type="text/css" href="/topjui/css/topjui.core.min.css" rel="stylesheet">
    <link type="text/css" href="/topjui/themes/default/topjui.bluelight.css" rel="stylesheet" id="dynamicTheme"/>
    <!-- FontAwesome字体图标 -->
    <link type="text/css" href="/static/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
    <!-- layui框架样式 -->
    <link type="text/css" href="/static/plugins/layui/css/layui.css" rel="stylesheet"/>
    <link type="text/css" href="/topjui/css/myui.css" rel="stylesheet"/>
    <link rel="stylesheet" href="/static/plugins/raty/jquery.raty.css">
    <script type="text/javascript" src="/static/public/js/topjui.config.js"></script>
    <!-- layui框架js -->
    <script type="text/javascript" src="/static/plugins/layui/layui.js" charset="utf-8"></script>
    <script src="/easyui/jquery.min.js"></script>
    <script src="/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/topjui/js/sysutils.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=lqVkw7DAWGt8CA9NAzxGWrQq"></script>
    <script src="/static/plugins/raty/jquery.raty.js"></script>
</head>

<body>

<table id="rowgrid" class="topjui-datagrid"></table>

<script type="text/javascript" charset="utf-8" th:inline="none">
    var listgrid;
    $(function(){
        listgrid = $('#rowgrid').datagrid({
            url:"/report/taskList",
            method:'get',
            fit : true,
            fitColumns : true,
            border : false,
            pagination : false,
            nowrap : false,
            columns:[[
                {
                    field:'booardname',
                    title:'配电房名称',
                    width:60
                }, {
                    field:'projectcode',
                    title:'所属项目编码',
                    width:40
                }, {
                    field:'factoryname',
                    title:'所属单位名称',
                    width:60
                }, {
                    field:'usertype',
                    title:'用户类型',
                    hidden:true
                },  {
                    field:'routername',
                    title:'巡视单位',
                    width:60
                }, {
                    field:'op',
                    title:'派单次数',
                    width:30,
                    align:'right',
                    formatter:function (value,row,index) {
                        return"<span style='color: #00a65a'>"+value+"</span>"
                    }
                }, {
                    field:'op40',
                    title:'设备清扫',
                    width:30,
                    align:'center',
                    formatter:function (value,row,index) {
                        if(value==0){
                            return "<img src='/static/admin/images/cancel.png'>"
                        }else if(value==1){
                            return "<img src='/static/admin/images/ok.png'>"
                        }else{
                            return "<img src='/static/admin/images/tip.png' title='任务没有及时完成'>"
                        }
                    }
                }, {
                    field:'op50',
                    title:'巡视',
                    width:30,
                    align:'center',
                    formatter:function (value,row,index) {
                        if(value==0){
                            return "<img src='/static/admin/images/cancel.png'>"
                        }else if(value==1){
                            return "<img src='/static/admin/images/ok.png'>"
                        }else{
                            return "<img src='/static/admin/images/tip.png' title='任务没有及时完成'>"
                        }
                    }
                }, {
                    field:'op60',
                    title:'红外测温',
                    width:30,
                    align:'center',
                    formatter:function (value,row,index) {
                        if(value==0){
                            return "<img src='/static/admin/images/cancel.png'>"
                        }else if(value==1){
                            return "<img src='/static/admin/images/ok.png'>"
                        }else{
                            return "<img src='/static/admin/images/tip.png' title='任务没有及时完成'>"
                        }
                    }
                }, {
                    field:'op70',
                    title:'开关核对',
                    width:30,
                    align:'center',
                    formatter:function (value,row,index) {
                        if(value==0){
                            return "<img src='/static/admin/images/cancel.png'>"
                        }else if(value==1){
                            return "<img src='/static/admin/images/ok.png'>"
                        }else{
                            return "<img src='/static/admin/images/tip.png' title='任务没有及时完成'>"
                        }
                    }
                }, {
                    field:'op80',
                    title:'环境清扫',
                    width:30,
                    align:'center',
                    formatter:function (value,row,index) {
                        if(value==0){
                            return "<img src='/static/admin/images/cancel.png'>"
                        }else if(value==1){
                            return "<img src='/static/admin/images/ok.png'>"
                        }else{
                            return "<img src='/static/admin/images/tip.png' title='任务没有及时完成'>"
                        }
                    }
                }
            ]],
            toolbar:[{
                text:'查询',
                iconCls : 'fa fa-search',
                btnCls: 'topjui-btn-normal',
                handler : function() {
                    list_search();
                }
            },'-', {
                text:'导出',
                iconCls : 'fa fa-file-excel-o',
                btnCls: 'topjui-btn-normal',
                handler : function() {
                    roomtask_excel();
                }
            },'-', {
                text:'刷新',
                iconCls : 'fa fa-refresh',
                btnCls: 'topjui-btn-green',
                handler : function() {
                    listgrid.datagrid('reload');
                }
            }],
            onDblClickRow :function(rowIndex,rowData){
                list_editMapFun(rowData.id);
            }
        });
    });

    function list_search(){
        $('<div/>').dialog({
            href : "/report/mapa",
            width : 390,
            height : 200,
            modal : true,
            title : '查询',
            buttons : [{
                text : '查询',
                iconCls : 'fa fa-search',
                btnCls: 'topjui-btn-normal',
                handler : function() {
                    var d = $(this).closest('.window-body');
                    var param = form2Json("search_form");
                    $('#search_form').form('submit', {
                        url : '/report/roomTaskList',
                        onSubmit:function(){
                            return true;
                        },
                        success : function(result) {
                            try {
                                var r = $.parseJSON(result);
                                listgrid.datagrid({
                                    url:'/report/roomTaskList',
                                    pagination : false,
                                    idField : 'id',
                                    queryParams: param,　　//关键之处
                                    data:r
                                });
                                d.dialog('destroy');

                            } catch (e) {
                                $.messager.alert('提示', result);
                            }
                        }
                    });
                }
            }],
            onClose : function() {
                $(this).dialog('destroy');
            },
            onLoad : function() {
                //运维类型
                $.ajax({
                    type:'get',
                    url:'/router/allList',
                    cache:false,
                    dataType:'json',
                    success:function(response){
                        console.log(response);
                        if(response.code == '200'){
                            secondDatas = response.result;
                            console.log(secondDatas);
                            //遍历回传的数据添加到二级select
                            $("#routerid").append("<option value='0'>请选择</option>>");
                            $.each(secondDatas, function(key, secondData) {
                                var option = '<option value="'+secondData.id+'">'+secondData.name+'</option>';
                                $("#routerid").append(option);
                            });
                            //二级select展示
                            $("#routerid").fadeIn("slow");
                        }
                    },
                    error:function(){
                        alert("请求失败")
                    }
                });
                //日期样式
                $('#form-taskdate').datebox({
                    required: true,
                    formatter:ww4,
                    parser:w4
                });
                $(".combo-text").removeAttr("style");
                $(".combo-text").attr("style", "width:250px;height:24px;line-height:24px");
                $(".combo-text").addClass("selectp");
                $(".combo-arrow").attr("style", "margin-left: -20px;margin-top: 3px;background-color:rgba(0,0,0,0)");
                $(".combo-panel").attr("style", "margin-top:0px;");
            }
        });
    }
    function ww4(date){
        var y = date.getFullYear();
        var m = date.getMonth()+1;
        var d = date.getDate();
        //return  y+'-'+(m<10?('0'+m):m);
        return  y+(m<10?('0'+m):""+m);
    }
    function w4(s){
        if (!s) {
            return new Date();
        }else{
            console.log(s);
            var y = s.substring(0,4);
            var m = s.substring(4,7);
            console.log(y);
            console.log(m);
            return new Date(y,m-1);
        }

    }

    function roomtask_excel(){
        $('<div/>').dialog({
            href : "/report/mapa",
            width : 390,
            height : 200,
            modal : true,
            title : '数据导出',
            buttons : [{
                text : '下载',
                iconCls : 'fa fa-search',
                btnCls: 'topjui-btn-normal',
                handler : function() {
                    var d = $(this).closest('.window-body');
                    var param = form2Json("search_form");
                    download('/report/roomTaskListExcel',param,'post');
                    d.dialog('destroy');
                }
            }],
            onClose : function() {
                $(this).dialog('destroy');
            },
            onLoad : function() {
                //运维类型
                $.ajax({
                    type:'get',
                    url:'/router/allList',
                    cache:false,
                    dataType:'json',
                    success:function(response){
                        console.log(response);
                        if(response.code == '200'){
                            secondDatas = response.result;
                            console.log(secondDatas);
                            //遍历回传的数据添加到二级select
                            $("#routerid").append("<option value='0'>请选择</option>>");
                            $.each(secondDatas, function(key, secondData) {
                                var option = '<option value="'+secondData.id+'">'+secondData.name+'</option>';
                                $("#routerid").append(option);
                            });
                            //二级select展示
                            $("#routerid").fadeIn("slow");
                        }
                    },
                    error:function(){
                        alert("请求失败")
                    }
                });
                //日期样式
                $('#form-taskdate').datebox({
                    required: true,
                    formatter:ww4,
                    parser:w4
                });
                $(".combo-text").removeAttr("style");
                $(".combo-text").attr("style", "width:250px;height:24px;line-height:24px");
                $(".combo-text").addClass("selectp");
                $(".combo-arrow").attr("style", "margin-left: -20px;margin-top: 3px;background-color:rgba(0,0,0,0)");
                $(".combo-panel").attr("style", "margin-top:0px;");
            }
        });
    }
</script>

</body>
</html>